package com.itboye.hutouben.util;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;

/**
 * Created by itboye on 2016/12/9.
 */

public class ClipImageBorderView extends View
    {
        /**
         * ˮƽ������View�ı߾�
         */
        private int mHorizontalPadding;
        /**
         * �߿�Ŀ�� ��λdp
         */
        private int mBorderWidth = 2;

        private Paint mPaint;

        public ClipImageBorderView(Context context)
        {
            this(context, null);
        }

        public ClipImageBorderView(Context context, AttributeSet attrs)
        {
            this(context, attrs, 0);
        }

        public ClipImageBorderView(Context context, AttributeSet attrs, int defStyle)
        {
            super(context, attrs, defStyle);

            mBorderWidth = (int) TypedValue.applyDimension(
                    TypedValue.COMPLEX_UNIT_DIP, mBorderWidth, getResources()
                            .getDisplayMetrics());
            mPaint = new Paint();
            mPaint.setAntiAlias(true);
        }

        @Override
        protected void onDraw(Canvas canvas)
        {
            super.onDraw(canvas);
            // ���Ʊ߿�
            mPaint.setColor(Color.parseColor("#FFFFFF"));
            mPaint.setStrokeWidth(mBorderWidth);
            mPaint.setStyle(Paint.Style.STROKE);
            //���α߿�
//		canvas.drawRect(mHorizontalPadding, mVerticalPadding, getWidth()- mHorizontalPadding, getHeight() - mVerticalPadding, mPaint);
            //Բ�α߿�
            canvas.drawCircle( getWidth()/2, getHeight()/2, getWidth()/2-mHorizontalPadding, mPaint);

        }

    public void setHorizontalPadding(int mHorizontalPadding)
    {
        this.mHorizontalPadding = mHorizontalPadding;

    }
}
